﻿Imports DTO
Imports System.Data.SqlClient
Public Class CChoMuonSachDAO

    Public Function ChoMuonSach(ByRef _phieumuon As CChoMuonSachDTO) As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspThemPhieuMuon", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As SqlParameter = New SqlParameter("@madocgia", _phieumuon.MaDocGia)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ngaymuon", _phieumuon.NgayMuon)
            cm.Parameters.Add(para)
            para = New SqlParameter("@matinhtrang", _phieumuon.TinhTrang)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ma", 0)
            para.Direction = ParameterDirection.Output

            cm.Parameters.Add(para)
            Dim n As Integer = cm.ExecuteNonQuery()
            _phieumuon.Ma = cm.Parameters("@ma").Value
            cn.Close()
            Return n

        End Using
    End Function

End Class
